package itstudio.instructor.ui;

import java.util.ArrayList;
import java.util.List;
import itstudio.instructor.adapter.UserListAdapter;
import itstudio.instructor.entity.User;
import itstudio.instructor.xlistview.XListView;
import com.easemob.chatuidemo.R;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

public class UesrPubFragment extends Fragment {
	
    private View rootView ;
    private XListView xListView;
    private UserListAdapter adapter;
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
        if (rootView == null) {
            rootView = inflater.inflate(R.layout.xlistview, container,false);
            bindViews();
        }
        ViewGroup parent = (ViewGroup) rootView.getParent();
        if (parent != null) {
            parent.removeView(rootView);
        }
        return rootView;
	}
	private void bindViews() {
		xListView = (XListView) rootView.findViewById(R.id.xlistView);
		adapter = new UserListAdapter(getActivity(), null);
		xListView.setAdapter(adapter);
		xListView.setPullRefreshEnable(false);
		xListView.setPullLoadEnable(false);
		adapter.appendToList(testData());
	}
	private List<User> testData() {
		List<User> userList = new ArrayList<User>();
		User u1= new User();
		u1.setName("轻院超市");
		u1.setIntro("新鲜水果大促销，买一送一了");
		u1.setHeadUrl("drawable://"+R.drawable.t_user_1);
		u1.setFocus(false);
		userList.add(u1);
		User u2= new User();
		u2.setName("考研帮");
		u2.setIntro("考研，你准备好了吗");
		u2.setHeadUrl("drawable://"+R.drawable.t_user_2);
		u2.setFocus(true);
		userList.add(u2);
		User u3= new User();
		u3.setName("教务处");
		u3.setIntro("2015评教工作开始，大家赶快积极参与");
		u3.setHeadUrl("drawable://"+R.drawable.t_user_3);
		u3.setFocus(true);
		userList.add(u3);
		return userList;
	}
}
